class GreatwalksController < ApplicationController
  # GET /greatwalks
  # GET /greatwalks.xml
  before_filter :authorize
  layout "admin"

  def index
    @greatwalks = Greatwalk.find(:all)

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @greatwalks }
    end
  end

  # GET /greatwalks/1
  # GET /greatwalks/1.xml
  def show
    @greatwalk = Greatwalk.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @greatwalk }
    end
  end

  # GET /greatwalks/new
  # GET /greatwalks/new.xml
  def new
    @greatwalk = Greatwalk.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @greatwalk }
    end
  end

  # GET /greatwalks/1/edit
  def edit
    @greatwalk = Greatwalk.find(params[:id])
  end

  # POST /greatwalks
  # POST /greatwalks.xml
  def create
    @greatwalk = Greatwalk.new(params[:greatwalk])

    respond_to do |format|
      if @greatwalk.save
        flash[:notice] = 'Greatwalk was successfully created.'
        format.html { redirect_to(@greatwalk) }
        format.xml  { render :xml => @greatwalk, :status => :created, :location => @greatwalk }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @greatwalk.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /greatwalks/1
  # PUT /greatwalks/1.xml
  def update
    @greatwalk = Greatwalk.find(params[:id])

    respond_to do |format|
      if @greatwalk.update_attributes(params[:greatwalk])
        flash[:notice] = 'Greatwalk was successfully updated.'
        format.html { redirect_to(@greatwalk) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @greatwalk.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /greatwalks/1
  # DELETE /greatwalks/1.xml
  def destroy
    @greatwalk = Greatwalk.find(params[:id])
    @greatwalk.destroy

    respond_to do |format|
      format.html { redirect_to(greatwalks_url) }
      format.xml  { head :ok }
    end
  end
end
